<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04</title>
</head>

<body>
    <script>
        function* fibs() {
            let a = 0;
            let b = 1;
            while (true) {
                yield a;//yield是返回a的值的意思
                [a, b] = [b, a + b];
            }
        }

        let [first, second, third, fourth, fifth, sixth] = fibs();
        console.log(first, second, third, fourth, fifth, sixth);//全部接受的每一轮的值

        function f() {
            console.log('aaa');
        }

        let [x = f()] = [1];
        console.log(x);


        // 最下面的代码要＋小括号，因为 JavaScript 引擎会将{y}理解成一个代码块，从而发生语法错误。
        // 只有不将大括号写在行首，避免 JavaScript 将其解释为代码块，才能解决这个问题。
        let y;
        ({ y } = { y: 1 });

    </script>
</body>

</html>